package com.shuimin.as;

import com.shuimin.as.model.repair.AsShopExtra;
import pond.db.sql.Criterion;
import pond.web.Render;
import pond.web.RestfulRoutes;
import pond.web.restful.API;

import java.util.List;

/**
 * Created by sky on 2017/8/21.
 */
public class SHOP_EXTRA extends API {

    {
        new RestfulRoutes<>(this,App.DB, AsShopExtra.class).all();

        get("/get_by_shop/:id",(req,resp)->{
            String shop_id=req.param("id");
            AsShopExtra extra=App.DB.get(t->{
                List<AsShopExtra> list=t.recordsQuery(AsShopExtra.class,"shop_id", Criterion.EQ,shop_id);
                if(list.size()>0){
                    return list.get(0);
                }else return null;
            });
            resp.render(Render.json(extra));
        });
    }
}
